<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="Cache-Control" content="no-cache">
    <title>陕北矿业常态化运行管理系统</title>
    <!-- 样 式 文 件 -->
    <link rel="icon" href="./favicon.ico">
    <style>
          body {
            background-image: url('./admin/images/background-zjm-v1.png'); /* 替换为你的图片路径 */
            background-size: cover; /* 让背景图片覆盖整个元素 */
            background-repeat: no-repeat; /* 背景图片不重复 */
            background-position: center center; /* 背景图片居中显示 */
            background-attachment: fixed; /* 背景图片固定，不随滚动条滚动 */
        }
    </style>
    <script>
		addEventListener("load", function () {
			setTimeout(hideURLbar, 0);
		}, false);

		function hideURLbar() {
			window.scrollTo(0, 1);
		}
	</script>
	<!-- Meta tag Keywords -->
	<!-- css files -->
	<link rel="stylesheet" href="./login/css/style.css" type="text/css" media="all" />
	<!-- Style-CSS -->
	<link rel="stylesheet" href="./login/css/fontawesome-all.css">
</head>
<!-- 代 码 结 构 -->
<body>

<!-- bg effect -->
<!-- <div id="bg1">
    <canvas></canvas>
    <canvas></canvas>
    <canvas></canvas>
</div> -->
<!-- //bg effect -->
<!-- title -->
<!-- <h1>
    <img src="./admin/images/logo-sbky.png" width="540px" />
</h1> -->
<!-- //title -->
<!-- content -->
<div style="height: 200px;">

</div>
<div class="sub-main-w3" style="padding-left:550px;">
    <form class="layui-form" action="javascript:void(0);">
        <h2>
            <img src="./admin/images/logo.png"/>
        </h2>
        <div class="form-style-agile">
            <label>
                <i class="fas fa-user"></i>
                用户名
            </label>
            <input placeholder="账 号" name="userName" type="text" lay-verify="required" >
        </div>
        <div class="form-style-agile">
            <label>
                <i class="fas fa-unlock-alt"></i>
                密码
            </label>
            <input placeholder="密 码" name="password" type="password" lay-verify="password" >
        </div>
        <input type="submit" value="登录" lay-submit lay-filter="login">
    </form>
</div>
<!-- //content -->

<!-- copyright -->
<!-- <div class="footer" style="text-align: center;margin-bottom: 50px;">
    <span class="center jsFooter" style="cursor: pointer; color: #fff;">
        © 2024 陕北矿业信息技术运维分公司
    </span>
</div> -->
<!-- //copyright -->

<!-- Jquery -->
<script src="./login/js/jquery-3.3.1.min.js"></script>
<!-- //Jquery -->

<!-- effect js -->
<script src="./login/js/canva_moving_effect.js"></script>





<!-- 资 源 引 入 -->
<script src="component/layui/layui.js"></script>
<script src="component/pear/pear.js"></script>
<script src="scripts/utils/request.js"></script>

<script>

    localStorage.removeItem("token")
    localStorage.removeItem("userId")
    localStorage.removeItem("userName")
    localStorage.removeItem("roleType")
    localStorage.removeItem("mineId")
    localStorage.removeItem("mineName")
    localStorage.removeItem("isManager")

    var $,form,button,popup,notice,hashes;
    layui.use(['jquery','form', 'button', 'popup','notice','hashes'], function() {
         $ = layui.jquery;
         form = layui.form;
         button = layui.button;
         popup = layui.popup;
         notice= layui.notice;
         hashes= layui.hashes;

        // 自定义验证规则
        form.verify({
            password: function (value) {
                if (!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@#$%^&+=!])(?!.*\s).{4,50}$/.test(value)) {
                    return '请输入正确的密码格式（ps:至少包含大写字母、数字、特殊符号）';
                }
            }
        });


        // 登 录 提 交
        form.on('submit(login)', function(data) {
            data = data.field;
            data.password = btoa(data.password);
            console.log(data)
            postAjax('/api/auth/login',data,function (response){
                console.log(response)
                localStorage.setItem("token",response.data.token)
                localStorage.setItem("userId",response.data.id)
                localStorage.setItem("userName",response.data.userName)
                localStorage.setItem("roleType",response.data.roleType)
                localStorage.setItem("mineId",response.data.belongId)
                localStorage.setItem("mineName",response.data.belongName)
                localStorage.setItem("isManager",response.data.isManager)
                location.href = "./main.html"
            },null)
            button.load({
                elem: '.login',
                time: 1000,
                done: function() {
                    return false;
                }
            })
            return false;
        });
    })
</script>
</body>
</html>
